<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--<link href="/css/bootstrap.min.css" rel="stylesheet">-->
<link href="/fonts/iconfont/iconfont.css" rel="stylesheet">
<!--summernote css -->
<!--<link type="text/css" href="/css/plugins/summernote/summernote-lite.css" rel="stylesheet">-->
<!--<link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote-lite.css" rel="stylesheet">-->
<head th:include="cultivateWeb/header :: culHeaderCss"></head>

<body>
<!-- 顶部导航 -->
<header th:include="cultivateWeb/header :: header"></header>
<link type="text/css" href="/css/cultivateWeb/style/course.css" rel="stylesheet">

<style>
    .dis_row{
        display: flex;flex-direction: row;
    }
    .dis_column{
        display: flex;flex-direction: column;
    }
    .a_center{
        align-items: center;
    }
    .j_center{
        justify-content: center;
    }
    .discuss_top{
        background: #ffffff;margin-top: 0px;width: 100%;font-size: 16px;color: #999;
        border-bottom: 1px solid #dfdfdf;
       /* height: 150px;*/
        height: 80px;
    }
    .discuss_top_title{
        margin-top: 0px;width: 100%;color: #999;
        height: 80px;
    }
    .discuss_top_content{
        margin-top: 0px;width: 100%;color: #666;
        height: auto;
    }
    .discuss_list{
         background: #ffffff;margin-top: 0px;width: 100%;font-size: 16px;color: #999;
    }
    .discuss_buttons{
        margin-top: 0px;width: 100%;font-size: 16px;
        height: 200px;background-color: #f5f5f5;
    }
    .discuss_buttons_textarea{
        width: 85%;
        border: 1px solid #ccc;
        border-radius: 4px;
        color: #555;
        background: #ffffff;
        padding: 4px 4px;
    }
    .discuss_buttons_send{
        width: 100px;
        height: 35px;
        border-radius: 10px;
        background-color: #22ac38;
        color: #ffffff;
        text-align: center;

    }
</style>
<div style="background-color: #f7f7f7; ">
    <div class="layui-container">
        <p style="line-height: 40px">当前位置：<a href="/cultivate/homepage">首页</a> > <a
                href="/cultivate/courseIndex">培训课程</a> > 课程详情</p>
    </div>

    <div class="container">
        <div class="row">
            <section>
                <div class="img_box">
                    <p><img th:src="${cou.thumbnail}" class="courimg" style="margin: 0" id="courseImg"></p>
                    <div class="div_1">
                        <input type="hidden" id="courseId" th:value="${cou.id}"/>
                        <span class="span_1" th:text="${cou.name}"></span>
                        <!--            <span class="span_2">共<span style="color: red;">24</span>学时，<span style="color: red;">944</span>分钟</span>-->
                        <span class="span_2" th:if="${cou.specialPrice!='0.00'}">
                      优惠价：<span style="color:#fe7252;font-size:22px" th:text="￥+${cou.specialPrice}"></span>
                指导价：<span style="text-decoration: line-through;color:#999;font-size:14px"
                          th:text="￥+${cou.guidancePrice}"></span>&nbsp;&nbsp;&nbsp;&nbsp;
                </span>
                        <span class="span_2" th:if="${cou.specialPrice=='0.00'}">
                     <span style="color:#fe7252;font-size:22px">免费</span>
                </span>
                        <span class="span_2">课程类型：
                    <span th:if="${cou.type==0}">证书课程</span>
                    <span th:if="${cou.type==1}">师资培训课程</span>
                    <span th:if="${cou.type==2}">考评员培训课程</span>
                    <span th:if="${cou.type==3}">高级师资培训课程</span>
                    <span th:if="${cou.type==4}">高级考评员培训课程</span>
                </span>
                        <span class="span_2">讲师名：<span th:text="${cou.teacherName}"></span></span>
                        <span>
                            <div style="margin-left:10px;color:#fe7252">浏览：1832</div>
                    <!--<a th:href="@{'/traCourses/selCourseOrder?id='+${cou.id}}">-->
                         <input type="button" value="报名课程" onclick="submit()" class="btn"/>
                            <!--</a>-->
            </span>
                    </div>
                    <div style="clear: both"></div>
                </div>
                <div class="div_2">
                    <div style="height: 50px;display: flex">
                        <span class="span_3 active1">课程简介</span>
                        <span class="span_3">课程内容</span>
                        <!-- <span class="span_3">配套资源</span> -->
                        <span class="span_3">疑问讨论区</span>
                    </div>
                    <hr style="margin: auto"/>
                    <!-- 课程简介 -->
                    <div style="font-size: 14px;  margin: 30px;" id="introduce">
                        <p style="font-size: 14px;" th:if="${not #strings.isEmpty(cou.introduce)}"
                           th:text="${cou.introduce}"></p>
                        <p style="font-size: 14px;" th:if="${#strings.isEmpty(cou.introduce)}">暂无数据</p>
                    </div>
                    <!-- 课程章节 -->
                    <div style="font-size: 14px; margin:20px 0;display: none" id="chapterList">
                        <input id="selChapterListFirst" type="hidden" th:value="${selChapterList.size()>0?selChapterList[0].id:''}"/>
                        <input id="selChapterList" type="hidden" th:value="${selChapterList}"/>
                        <th:block >
                            <th:block th:each="item,loopStatus : ${selChapterList}" >
                                <th:block  th:with="chapterId=${item.id}" >
                                    <div class="list" style="display: flex;flex-direction: row;align-items: center; background: #e8f9ff;margin-top: 20px;">
                                        <div th:id="'icon_'+${chapterId}" style="margin-right: 2px">
                                            <i th:if="${loopStatus.count}==1" class="layui-icon layui-icon-down" aria-hidden="true"></i>
                                            <i th:if="${loopStatus.count}!=1" class="layui-icon layui-icon-right" aria-hidden="true"></i>
                                        </div>
                                        <span th:onclick="'javascript:ShrinkChapter(\''+${item.id}+'\')'" class="chapterTitle" th:style="'margin-left:' + ${item.level*30}+'px;width: '+${100-(item.level*3)}+'%;font-size: 16px; background: #e8f9ff;color: #666;'" th:text="${item.name}" ></span>
                                        <div style="display: flex;flex-direction: row;align-items: center;justify-content: flex-end">

                                            <th:block  th:if="${item.isHaveResources}==1">
                                                <th:block th:each="res : ${item.resources}" >
                                                    <a th:href="'/couInfo/couInfo/trainingResourcesDetails?id='+${item.id}+'&resourceId='+${res.id}+'&rindex='+${res.rindex}" target="_blank">
                                                        <th:block  th:if="${res.type}==0">
                                                            <i class="iconfont icon-wendang" aria-hidden="true" style="margin-right: 30px;color: #d6204b;font-size: 20px;"></i>
                                                        </th:block>
                                                        <th:block  th:if="${res.type}==1">
                                                            <i class="iconfont icon-icon-test" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                        </th:block>
                                                        <th:block  th:if="${res.type}==2">
                                                            <i class="iconfont icon-ppt" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                        </th:block>
                                                        <th:block  th:if="${res.type}==3">
                                                            <i class="layui-icon layui-icon-file" aria-hidden="true" style="margin-right: 30px"></i>
                                                        </th:block>
                                                        <th:block  th:if="${res.type}==4">
                                                            <i class="iconfont icon-icon-test1" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                        </th:block>
                                                        <th:block  th:if="${res.type}==5">
                                                            <i class="iconfont icon-icon-test" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                        </th:block>
                                                    </a>
                                                </th:block>
                                            </th:block>

                                        </div>
                                    </div>
                                    <div style=" margin:20px 0;display: none" th:class="'chapter_'+${chapterId}" th:name="'chapter_'+${chapterId}" th:id="'chapter_'+${chapterId}" >
                                        <th:block  th:if="${item.isHaveChildren+''=='1'}" th:with="titleFontSize=15">
                                            <th:block th:each="item2 : ${item.children}" >
                                                <th:block >
                                                    <div class="list" style="margin-top: 10px;">
                                                        <div  class="chapterTitle"  th:style="'margin-left:' + ${item2.level*30}+'px;width: '+${100-(item2.level*3)}+'%;font-size: '+${titleFontSize}+'px;color: #666;display: flex;justify-content: space-between;flex-direction: row;align-items: center; background: #ffffff;'">
                                                            <span  th:text="${item2.name}"></span>
                                                            <div class="chapterIcon">
                                                                <th:block  th:if="${item2.isHaveResources}==1">
                                                                    <th:block th:each="res2 : ${item2.resources}" >
                                                                        <a th:href="'/couInfo/couInfo/trainingResourcesDetails?id='+${item2.id}+'&resourceId='+${res2.id}+'&rindex='+${res2.rindex}" target="_blank">
                                                                            <th:block  th:if="${res2.type}==0">
                                                                                <i class="iconfont icon-wendang" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                            </th:block>
                                                                            <th:block  th:if="${res2.type}==1">
                                                                                <i class="iconfont icon-icon-test" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                            </th:block>
                                                                            <th:block  th:if="${res2.type}==2">
                                                                                <i class="iconfont icon-ppt" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                            </th:block>
                                                                            <th:block  th:if="${res2.type}==3">
                                                                                <i class="layui-icon layui-icon-file" aria-hidden="true" style="margin-right: 30px"></i>
                                                                            </th:block>
                                                                            <th:block  th:if="${res2.type}==4">
                                                                                <i class="iconfont icon-icon-test1" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                            </th:block>
                                                                            <th:block  th:if="${res2.type}==5">
                                                                                <i class="iconfont icon-icon-test" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                            </th:block>
                                                                        </a>
                                                                    </th:block>
                                                                </th:block>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <th:block  th:if="${item2.isHaveChildren+''=='1'}" th:with="titleFontSize=14">
                                                        <th:block th:each="item3 : ${item2.children}" >
                                                            <th:block >
                                                                <div class="list" style="color: #666;margin-top: 10px;" >
                                                                    <div  class="chapterTitle"  th:style="'margin-left:' + ${item3.level*30}+'px;width: '+${100-(item3.level*3)}+'%;font-size: '+${titleFontSize}+'px;color: #666;display: flex;justify-content: space-between;flex-direction: row;align-items: center; background: #ffffff;'" >
                                                                        <span th:text="${item3.name}"></span>
                                                                        <div class="chapterIcon">
                                                                            <th:block  th:if="${item3.isHaveResources}==1">
                                                                                <th:block th:each="res3 : ${item3.resources}" >
                                                                                    <a th:href="'/couInfo/couInfo/trainingResourcesDetails?id='+${item3.id}+'&resourceId='+${res3.id}+'&rindex='+${res3.rindex}" target="_blank">
                                                                                        <th:block  th:if="${res3.type}==0">
                                                                                            <i class="iconfont icon-wendang" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                                        </th:block>
                                                                                        <th:block  th:if="${res3.type}==1">
                                                                                            <i class="iconfont icon-icon-test" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                                        </th:block>
                                                                                        <th:block  th:if="${res3.type}==2">
                                                                                            <i class="iconfont icon-ppt" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                                        </th:block>
                                                                                        <th:block  th:if="${res3.type}==3">
                                                                                            <i class="layui-icon layui-icon-file" aria-hidden="true" style="margin-right: 30px"></i>
                                                                                        </th:block>
                                                                                        <th:block  th:if="${res3.type}==4">
                                                                                            <i class="iconfont icon-icon-test1" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                                        </th:block>
                                                                                        <th:block  th:if="${res3.type}==5">
                                                                                            <i class="iconfont icon-icon-test" aria-hidden="true" style="margin-right: 30px;color: #f68859;font-size: 20px;"></i>
                                                                                        </th:block>
                                                                                    </a>
                                                                                </th:block>
                                                                            </th:block>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </th:block>
                                                        </th:block>
                                                    </th:block>
                                                </th:block>
                                            </th:block>
                                        </th:block>
                                    </div>
                                </th:block>
                            </th:block>
                        </th:block>
                    </div>
                    <!-- 扩展资料 -->
                    <!-- <div style="font-size: 14px; margin:20px 0;display: none" id="extendList"></div> -->
                    <!-- 课程疑问讨论区 -->
                    <div style="display: none" id="courseAndAsk">
                        <input type="hidden" id="coursesId" name="coursesId" th:value="${coursesId}"/>
                        <input type="hidden" id="rootId" name="rootId" value="-1"/>
                        <!--<div class="list dis_column discuss_top" >
                               <div class="dis_row a_center discuss_top_title">
                                   <span style="width: 80%;font-size: 18px;">讨论区</span>
                                   <span style="width: 20%;color: #fe7252;font-size: 12px;">讨论区使用规则</span>
                               </div>
                              <div class="dis_row a_center discuss_top_content">
                                   欢迎进入课程讨论区! ......
                               </div>
                           </div>-->
                        <div id="sendMessageDiv" class="dis_column a_center discuss_buttons" style="margin-top: 10px;">
                            <div id="messageDiv"  class="dis_row a_center j_center discuss_buttons_textarea" style="border: 1px solid #ccc;border-radius: 4px;margin-top: 20px">
                                    <textarea id="message"  name="message" placeholder="留下你的评论..."
                                              style="text-align: start; border: 0;width: 98%;height: 80px; resize: none;"
                                    ></textarea>
                            </div>
                            <div class="dis_row a_center j_center discuss_buttons_textarea" style="margin-top: 5px;border:0;background-color: #f5f5f5;">
                                <div style="width: 80%;"  class=" dis_row a_center">
                                    <input type="checkbox" id="isAnonymous" name="isAnonymous"/><label style="margin-left: 5px;color: #666">匿名</label>
                                </div>
                                <div  style="width: 20%;justify-content: flex-end;" class=" dis_row a_center">
                                    <div onclick="toSendMessage(-1)" class="discuss_buttons_send dis_row a_center j_center ">
                                        发布
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div style="font-size: 14px; margin:0px;" id="courseAsk">
                            <div id="commentListDiv" style="width: 100%;">
                                <!--<div class="dis_row a_center j_center discuss_buttons_textarea" style="margin-top: 5px;width: 200px;height: 80px;background-color: #fff; border:0;border-bottom: 3px solid #22ac38;font-size: 18px;">
                                    当前评论数：0
                                </div>
                                <div style="margin-top: 50px;"></div>
                                <div id="commentList" class="dis_column a_center j_center discuss_list" style="height: auto;">
                                    <div class="discuss_list dis_column a_center j_center">
                                        <div class="dis_row a_center discuss_list" style="height: 80px;width: 82%;">
                                            <div class="dis_row a_center discuss_list" style="width: 80px;">
                                                <img src="https://jinzhiweiye.oss-cn-hangzhou.aliyuncs.com/2021/05/31/45b046178c554ac98dfaa796a549aa7c222.jpg" style="height: 50px;width: 50px;border-radius: 50px;">
                                            </div>
                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">
                                                e123456
                                            </div>
                                            <div class="dis_row a_center j_center discuss_list" style="height: 35px;width: 80px;margin-left: 7px;color: #fe490a;border: 1px solid #fe490a;border-radius: 4px;">
                                                讲师
                                            </div>
                                            &lt;!&ndash;<div class="dis_row a_center j_center discuss_list" style="height: 35px;width: 80px;margin-left: 7px;color: #ffffff;background-color: #fe7252;border-radius: 4px;">
                                                讲师
                                            </div>
                                            <div class="dis_row a_center j_center discuss_list" style="height: 35px;width: 80px;margin-left: 7px;color: #ffffff;background-color:  #fe9157;border-radius: 4px;">
                                                学生
                                            </div>&ndash;&gt;
                                        </div>
                                        <div class="dis_row a_center j_center discuss_list" style="height: auto;width: 82%;">
                                            <div class="dis_row a_center discuss_list" style="width: 90%;margin-left: 10%;">
                                                e123456544444444444444444444444444444444444444444444444444123
                                            </div>
                                        </div>
                                        <div class="dis_row a_center j_center discuss_list" style="height: 1px;background-color: #E2E2E2;margin-top: 20px; margin-bottom: 20px;"></div>
                                        <div class="dis_column j_center discuss_list" style="width: 70%;height: 100px;margin-left: 15%;background-color: #f5f5f5;">
                                            <div class="dis_row a_center j_center discuss_list" style="height: 80px;background-color: #f5f5f5;">
                                                <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 10px;color: #000;background-color: #f5f5f5;">
                                                    e123456:
                                                </div>
                                                <div class="dis_row a_center discuss_list" style="width: 90%;height: 80px;margin-left: 7px;overflow: hidden;background-color: #f5f5f5;">
                                                    e123456544444444444444444444444444444444444444444444444444123e123456544444444444444444444444444444444444444444444444444123
                                                </div>
                                            </div>
                                        </div>

                                        <div class="dis_row a_center j_center discuss_list" style="height: 80px;width: 82%;">
                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;">
                                                16小时前
                                            </div>
                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;justify-content: flex-end;">
                                                <span>删除</span>
                                                <span style="margin-left: 10px;">回复(152)</span>
                                                <span style="margin-left: 10px;">...</span>
                                            </div>
                                        </div>
                                        <div class="dis_row a_center j_center discuss_list" style="height: 10px;background-color: #f7f7f7; "></div>
                                    </div>
                                    <div class="discuss_list dis_column a_center j_center">
                                        <div class="dis_row a_center discuss_list" style="height: 80px;width: 82%;">
                                            <div class="dis_row a_center discuss_list" style="width: 80px;">
                                                <img src="https://jinzhiweiye.oss-cn-hangzhou.aliyuncs.com/2021/05/31/45b046178c554ac98dfaa796a549aa7c222.jpg" style="height: 50px;width: 50px;border-radius: 50px;">
                                            </div>
                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">
                                                e123456
                                            </div>
                                            <div class="dis_row a_center j_center discuss_list" style="height: 35px;width: 80px;margin-left: 7px;color: #fe490a;border: 1px solid #fe490a;border-radius: 4px;">
                                                讲师
                                            </div>
                                        </div>
                                        <div class="dis_row a_center j_center discuss_list" style="height: auto;width: 82%;">
                                            <div class="dis_row a_center discuss_list" style="width: 90%;margin-left: 10%;">
                                                e123456544444444444444444444444444444444444444444444444444123
                                            </div>
                                        </div>
                                        &lt;!&ndash;<div class="dis_row a_center j_center discuss_list" style="height: 1px;background-color: #E2E2E2;margin-top: 20px; "></div>&ndash;&gt;
                                        <div class="dis_row a_center j_center discuss_list" style="height: 80px;width: 82%;">
                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;">
                                                16小时前
                                            </div>
                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;justify-content: flex-end;">
                                                <span>删除</span>
                                                <span style="margin-left: 10px;">回复(152)</span>
                                                <span style="margin-left: 10px;">...</span>
                                            </div>
                                        </div>
                                        <div class="dis_row a_center j_center discuss_list" style="height: 10px;background-color: #f7f7f7; "></div>
                                    </div>
                                </div>

                                <div class="discuss_list dis_column a_center j_center">
                                    <div class="dis_row a_center discuss_list" style="height: 80px;width: 82%;">
                                        <div class="dis_row a_center discuss_list" style="width: 80px;">
                                            <img src="https://jinzhiweiye.oss-cn-hangzhou.aliyuncs.com/2021/05/31/45b046178c554ac98dfaa796a549aa7c222.jpg" style="height: 50px;width: 50px;border-radius: 50px;">
                                        </div>
                                        <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">
                                            e123456
                                        </div>
                                        <div class="dis_row a_center j_center discuss_list" style="height: 35px;width: 80px;margin-left: 7px;color: #fe9157;border: 1px solid #fe9157;border-radius: 4px;">
                                            学生
                                        </div>
                                        <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto;margin-left: 7px;color: #999;background-color: #e8f9ff;border-radius: 4px;padding: 5px 5px;">
                                            123456班
                                        </div>
                                    </div>
                                    <div class="dis_row a_center j_center discuss_list" style="height: auto;width: 82%;">
                                        <div class="dis_row a_center discuss_list" style="width: 90%;margin-left: 10%;">
                                            e123456544444444444444444444444444444444444444444444444444123
                                        </div>
                                    </div>
                                    &lt;!&ndash;<div class="dis_row a_center j_center discuss_list" style="height: 1px;background-color: #E2E2E2;margin-top: 20px; "></div>&ndash;&gt;
                                    <div class="dis_row a_center j_center discuss_list" style="height: 80px;width: 82%;">
                                        <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;">
                                            16小时前
                                        </div>
                                        <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;justify-content: flex-end;">
                                            <span>删除</span>
                                            <span style="margin-left: 10px;">回复(152)</span>
                                            <span style="margin-left: 10px;">...</span>
                                        </div>
                                    </div>
                                    <div class="dis_row a_center j_center discuss_list" style="height: 10px;background-color: #f7f7f7; "></div>
                                </div>
                            -->
                            </div>

                            <div id="subCommentListDiv" style="width: 100%;">

                            </div>
                        </div>

                            <!--<div class="ibox-content no-padding">
                                <div id="content_sn" class="summernote" style="width: 600px;height: 500px;"></div>
                            </div>-->
                        <div id="page" class="page"></div>
                    </div>

                    <!-- 分页  -->
                </div>

                <!--<div class="div_3">-->
                <!--<div>-->
                <!--<span class="jp">精品推荐</span>-->
                <!--<hr style="margin: auto"/>-->
                <!--<span><img src="wx.png" style="width: 250px;height: 220px;border: 0"></span>-->
                <!--<span class="kc">精品课程1号</span>-->
                <!--</div>-->
                <!--</div>-->
            </section>
        </div>
    </div>
</div>

<!-- footer ------------------------------------------------------- -->
<div class="footer" th:include="cultivateWeb/header :: footer"></div>
</body>
<script src="/js/jquery.min.js"></script>
<script type="text/javascript" src="/js/xlPaging.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>
<!--summernote-->
<!--<script src="/js/plugins/summernote/summernote-lite.js"></script>-->
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.12/summernote-lite.js"></script>-->
<script>
    let CommentList = [];
    let rootItem = [];
    $(function () {
        $("#message").focus(function(){
            $("#messageDiv").css("border","1px solid #22ac38");
        });

        /*$('.summernote').summernote({
            height : '220px',
            lang : 'zh-CN',
            callbacks: {
                onImageUpload: function(files, editor, $editable) {
                    sendFile(files);
                }
            }
        });*/
        /*let selChapterList = $("#selChapterList").val();
        console.log("selChapterList:"+JSON.stringify(selChapterList));*/
        let selChapterListFirst = $("#selChapterListFirst").val();
        // console.log("selChapterListFirst:"+selChapterListFirst);
        $("#chapterList").find(".chapter_" + selChapterListFirst).toggle();
        $(".span_3").click(function () {
            $(this).addClass("active1");
            $(this).siblings().removeClass("active1");
            if ($(this).text() == '课程简介') {
                $("#introduce").show();
                $("#chapterList").hide();
                $('#extendList').hide();
                $('#courseAndAsk').hide();
            } else if ($(this).text() == '课程内容') {
                $("#introduce").hide();
                $("#chapterList").show();
                $('#extendList').hide();
                $('#courseAndAsk').hide();
            }else if ($(this).text() == '配套资源'){
                $("#introduce").hide();
                $("#chapterList").hide();
                $('#extendList').show();
                $('#courseAndAsk').hide();
            }else if ($(this).text() == '疑问讨论区'){
                getCommentList();
                $("#chapterList").hide();
                $("#courseAndAsk").show();
                $('#extendList').hide();
                $('#introduce').hide();
            }
        });
        selExtendList();
        //selChapterList();
        //questions();

    });
    function toDeleteComment(id){
        if(id=='' || id==undefined || id=='undefined'){
            flag = false;
            layer.alert("参数错误！");
        }
        if(flag){
            ajaxToken("/jzApi/courses/deleteComment", 'POST',
                {
                    id: id
                }, function (res) {
                    /*console.log("res:"+res);
                    console.log("res:"+JSON.stringify(res));*/
                    if (res== 1) {
                        layer.msg("评论已删除！");
                        if(rootId!=-1 && rootId!='' && rootId!=undefined && rootId!='undefined'){
                            getSubCommentList(rootId);
                        }else {
                            getCommentList();
                        }
                    }else {
                        layer.alert(res);
                    }
                }
            )
        }


    }
    function toSendMessage(pid){
        let coursesId = $("#coursesId").val();
        let message = $("#message").val();
        let rootId = $("#rootId").val();
        let isAnonymous = '';

        if(document.getElementById("isAnonymous").checked){
            isAnonymous = 1;
        }else {
            isAnonymous = 0;
        }
        /*console.log("message:"+message);
        console.log("isAnonymous:"+isAnonymous);
        console.log("pid:"+pid);*/
        let flag = true;
        if(message=='' || message==undefined || message=='undefined'){
            flag = false;
            layer.alert("请输入评论内容！");
        }
        if(flag){
            ajaxToken("/jzApi/courses/addComment", 'POST',
                {
                    message: message,
                    isAnonymous: isAnonymous,
                    pid: pid,
                    rootId: rootId,
                    coursesId: coursesId
                }, function (res) {
                    console.log("res:"+res);
                    console.log("res:"+JSON.stringify(res));
                    if (res== 1) {
                        //清空
                        document.getElementById("isAnonymous").checked=false;
                        $("#message").val("");
                        layer.msg("评论已提交！");
                        if(rootId!=-1 && rootId!='' && rootId!=undefined && rootId!='undefined'){
                            getSubCommentList(rootId);
                        }else {
                            getCommentList();
                        }
                    }else {
                        layer.alert(res);
                    }
                }
            )
        }


    }
    function getCommentList(){
        $.ajax({
            url: "/jzApi/courses/selCommentList",
            type: 'GET',
            data: {
                id: $("#courseId").val(),
                rootId: '',
                current:1,
                number:10
            },
            success: function (res) {
                //console.log("res:"+JSON.stringify(res));
                if (res.data == 0) {

                    $("#commentListDiv").html('         <div class="dis_row a_center j_center discuss_buttons_textarea" style="margin-top: 5px;width: 200px;height: 80px;background-color: #fff; border:0;border-bottom: 3px solid #22ac38;font-size: 18px;">\n' +
                        '                                    当前评论数：0\n' +
                        '                                </div>\n' +
                        '                                <div style="margin-top: 50px;"></div>' +
                        '                                <div id="commentList" class="dis_column a_center j_center discuss_list" style="height: 100px;">\n' +
                        '                                    暂无记录~\n' +
                        '                                </div>');
                } else {
                    let list = res.data;
                    CommentList = list;
                    let commentList = '<div class="dis_row a_center j_center discuss_buttons_textarea" style="margin-top: 5px;width: 200px;height: 80px;background-color: #fff; border:0;border-bottom: 3px solid #22ac38;font-size: 18px;">\n' +
                        '                                    当前评论数：'+list.length+'\n' +
                        '                                </div>\n' +
                        '                                <div style="margin-top: 50px;"></div>';
                    list.forEach(function (item, index) {

                        commentList += '<div class="discuss_list dis_column a_center j_center">\n' +
                            '                                        <div class="dis_row a_center discuss_list" style="height: 80px;width: 82%;">\n' ;
                        let margin_str="";
                        if(item.headPortrait==''){
                            margin_str="";
                            commentList += '';
                            //commentList += '                                  <div style="height: 50px;width: 50px;border-radius: 50px;border: 1px solid #999;"> </div>\n';
                        }else {
                            margin_str="margin-left: 5%;";
                            commentList +='                             <div class="dis_row a_center discuss_list" style="width: 80px;">\n'+
                                '                                           <img src="'+ item.headPortrait +'" style="height: 50px;width: 50px;border-radius: 50px;">\n'+
                                '                                        </div>\n' ;
                        }
                        if(item.isAnonymous==1){
                        commentList +=
                            '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">\n' +
                                                                             '匿名用户\n' +
                            '                                            </div>\n';
                        }else {
                        commentList +=
                            '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">\n' +
                                                                             item.userName+'\n' +
                            '                                            </div>\n';
                        if(item.isTeacher==1){
                            commentList +='                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px; margin-left: 7px;color: #fe490a;border: 1px solid #fe490a;border-radius: 4px;padding: 3px 5px;">\n' +
                            '                                                讲师\n' +
                            '                                            </div>\n';
                        }else if(item.isStudent==1){
                            commentList +='                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #fe9157;border: 1px solid #fe9157;border-radius: 4px;padding: 3px 5px;">\n' +
                                '                                            学生\n' +
                                '                                        </div>';
                        }else {
                            commentList +='                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #666;border: 1px solid #666;border-radius: 4px;padding: 3px 5px;">\n' +
                                '                                            其他用户\n' +
                                '                                        </div>';
                        }
                        if(item.classesName!=''){
                            commentList +='                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #999;background-color: #e8f9ff;border-radius: 4px;padding: 5px 5px;">\n' +
                                                                            item.classesName+' \n' +
                                '                                        </div>';
                        }
                        if(item.orgName!=''){
                            commentList +='                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #999;background-color: #e9fff4;border-radius: 4px;padding: 5px 5px;">\n' +
                                item.orgName+' \n' +
                                '                                        </div>';
                        }
                        }
                        if(rootItem.isDelete == 1){
                            commentList +='                              </div>\n' +
                                '                                        <div class="dis_row a_center j_center discuss_list" style="height: auto;width: 90%;">\n' +
                                '                                            <div class="dis_row a_center discuss_list" style="width: 90%;'+margin_str+'color: #666;">\n' +
                                                                                 '该评论已删除！\n' +
                                '                                            </div>\n' +
                                '                                        </div>\n';
                        }else {
                        commentList +='                              </div>\n' +
                            '                                        <div class="dis_row a_center j_center discuss_list" style="height: auto;width: 90%;">\n' +
                            '                                            <div class="dis_row a_center discuss_list" style="width: 90%;'+margin_str+'color: #666;">\n' +
                                                                            item.content+'\n' +
                            '                                            </div>\n' +
                            '                                        </div>\n';
                        }
                        if(item.children.length>0){
                            commentList +='                         <div class="dis_row a_center j_center discuss_list" style="height: 1px;background-color: #E2E2E2;margin-top: 20px; margin-bottom: 20px;"></div>\n'+
                                '                                   <div  onclick="reply('+index+',\''+item.id+'\')" class="dis_column j_center discuss_list" style="width: 70%;height: 100px;margin-left: 15%;background-color: #f5f5f5;">\n' +
                            '                                            <div class="dis_row a_center j_center discuss_list" style="height: 80px;background-color: #f5f5f5;">\n' +
                            '                                                <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 10px;color: #000;background-color: #f5f5f5;">\n' +
                                                                                item.children[0].userName+':\n' +
                            '                                                </div>\n' ;
                            if(item.children[0].isDelete==1){
                                commentList +='                                     <div class="dis_row a_center discuss_list" style="width: 90%;height: 80px;margin-left: 7px;overflow: hidden;background-color: #f5f5f5;color: #666;">\n' +
                                                                                     '该评论已删除！\n' +
                                    '                                                </div>\n' +
                                    '                                            </div>\n' +
                                    '                                        </div>\n' ;
                            }else {
                            commentList +='                                   <div class="dis_row a_center discuss_list" style="width: 90%;height: 80px;margin-left: 7px;overflow: hidden;background-color: #f5f5f5;color: #666;">\n' +
                                                                                item.children[0].content+'\n' +
                            '                                                </div>\n' +
                            '                                            </div>\n' +
                            '                                        </div>\n' ;
                            }
                        }
                        commentList +='\n' +
                            '                                        <div class="dis_row a_center j_center discuss_list" style="height: 80px;width: 82%;">\n' +
                            '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;font-size: 12px;">\n' +
                                                                            item.addTime+'\n' +
                            '                                            </div>\n' +
                            '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;justify-content: flex-end;font-size: 12px;color: #666;">\n';
                        if(item.isCurrentUser==1 && item.children.length==0){
                            commentList +='                                  <span onclick="toDeleteComment(\''+item.id+'\')" >删除</span>\n';
                        }
                        commentList +='                                      <span onclick="reply('+index+',\''+item.id+'\')" style="margin-left: 10px;">回复('+item.childrenSize+')</span>\n' +
                            '                                                <span style="margin-left: 10px;font-size: 18px;">...</span>\n' +
                            '                                            </div>\n' +
                            '                                        </div>\n' +
                            '                                        <div class="dis_row a_center j_center discuss_list" style="height: 10px;background-color: #f7f7f7; "></div>\n' +
                            '                                    </div>';
                    });
                    $("#commentListDiv").html(commentList);
                }
                page(1,res.data.pages);
            }
        });
    }
    function reply(index,rootId){
        rootItem = CommentList[index];
        console.log("rootItem:"+JSON.stringify(rootItem));
        $("#commentListDiv").hide();

        console.log("rootId:"+rootId);
        $("#rootId").val(rootId);
        let pageRootId = $("#rootId").val();
        console.log("pageRootId:"+pageRootId);
        getSubCommentList(rootId);
    }
    function replySub(pid){
        //console.log("rootId:"+rootId);
        $("#pid").val(pid);
        let pagePid = $("#pid").val();
        //console.log("pagePid:"+pagePid);

        //滚动到发布评论框 #sendMessageDiv
        var position = $("#sendMessageDiv").offset();
        position.top = position.top-250;
        $("html,body").animate({scrollTop:position.top}, 100);
        $("#message").focus();
        layer.msg("输入内容，发布即可回复");
    }
    function showRoot(){
        $("#commentListDiv").show();
        $("#subCommentListDiv").html("");
        getCommentList();
    }

    function getSubCommentList(rootId) {
        $("#subCommentListDiv").html("");
        $.ajax({
            url: "/jzApi/courses/selCommentList",
            type: 'GET',
            data: {
                id: $("#courseId").val(),
                rootId: rootId
            },
            success: function (res) {
               // console.log("res:"+JSON.stringify(res));
                let commentList = '<div class="layui-container">\n' +
                    '        <p onclick="showRoot()" style="line-height: 40px">< 返回</p>\n' +
                    '    </div>';
                //根评论
                commentList += '                 <div class="discuss_list dis_column a_center j_center">\n' +
                    '                                        <div class="dis_row a_center discuss_list" style="height: 80px;width: 82%;">\n';
                let margin_str = "";
                if (rootItem.headPortrait == '') {
                    margin_str = "";
                    commentList += '';
                } else {
                    margin_str = "margin-left: 5%;";
                    commentList += '                             <div class="dis_row a_center discuss_list" style="width: 80px;">\n' +
                        '                                           <img src="' + rootItem.headPortrait + '" style="height: 50px;width: 50px;border-radius: 50px;">\n' +
                        '                                        </div>\n';
                }
                if (rootItem.isAnonymous == 1) {
                    commentList +=
                        '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">\n' +
                        '匿名用户\n' +
                        '                                            </div>\n';
                } else {
                    commentList +=
                        '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">\n' +
                                                                         rootItem.userName + '\n' +
                        '                                            </div>\n';
                    if (rootItem.isTeacher == 1) {
                        commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px; margin-left: 7px;color: #fe490a;border: 1px solid #fe490a;border-radius: 4px;padding: 3px 5px;">\n' +
                            '                                                讲师\n' +
                            '                                            </div>\n';
                    } else if (rootItem.isStudent == 1) {
                        commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #fe9157;border: 1px solid #fe9157;border-radius: 4px;padding: 3px 5px;">\n' +
                            '                                            学生\n' +
                            '                                        </div>';
                    } else {
                        commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #666;border: 1px solid #666;border-radius: 4px;padding: 3px 5px;">\n' +
                            '                                            其他用户\n' +
                            '                                        </div>';
                    }
                    if (rootItem.classesName != '') {
                        commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #999;background-color: #e8f9ff;border-radius: 4px;padding: 5px 5px;">\n' +
                                                                         rootItem.classesName + ' \n' +
                            '                                        </div>';
                    }
                    if (rootItem.orgName != '') {
                        commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #999;background-color: #e9fff4;border-radius: 4px;padding: 5px 5px;">\n' +
                                                                         rootItem.orgName + ' \n' +
                            '                                        </div>';
                    }
                }
                if(rootItem.isDelete == 1){
                    commentList += '                              </div>\n' +
                        '                                        <div class="dis_row a_center j_center discuss_list" style="height: auto;width: 90%;">\n' +
                        '                                            <div class="dis_row a_center discuss_list" style="width: 90%;' + margin_str + 'color: #666;">\n' +
                                                                      '该评论已删除！\n' +
                        '                                            </div>\n' +
                        '                                        </div>\n';
                }else {
                commentList += '                              </div>\n' +
                    '                                        <div class="dis_row a_center j_center discuss_list" style="height: auto;width: 90%;">\n' +
                    '                                            <div class="dis_row a_center discuss_list" style="width: 90%;' + margin_str + 'color: #666;">\n' +
                                                                    rootItem.content + '\n' +
                    '                                            </div>\n' +
                    '                                        </div>\n';
                }
                commentList += '\n' +
                    '                                        <div class="dis_row a_center j_center discuss_list" style="height: 80px;width: 82%;">\n' +
                    '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;font-size: 12px;">\n' +
                                                                     rootItem.addTime + '\n' +
                    '                                            </div>\n' +
                    '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;justify-content: flex-end;font-size: 12px;color: #666;">\n';

                commentList +=
                    '                                            </div>\n' +
                    '                                        </div>\n' +
                    '                                        <div class="dis_row a_center j_center discuss_list" style="height: 10px;background-color: #f7f7f7; "></div>\n' +
                    '                                    </div>';



                if (res.data == 0) {

                    commentList +='                      <div class="dis_row a_center j_center discuss_buttons_textarea" style="margin-top: 5px;width: 200px;height: 80px;background-color: #fff; border:0;border-bottom: 3px solid #22ac38;font-size: 18px;">\n' +
                        '                                    回复数：0\n' +
                        '                                </div>\n' +
                        '                                <div style="margin-top: 50px;"></div>' +
                        '                                <div id="commentList" class="dis_column a_center j_center discuss_list" style="height: 100px;">\n' +
                        '                                    暂无记录~\n' +
                        '                                </div>';
                    $("#subCommentListDiv").html(commentList);
                } else {
                    let list = res.data;

                    //子评论
                    commentList += '                     <div class="dis_row a_center j_center discuss_buttons_textarea" style="margin-top: 5px;width: 200px;height: 80px;background-color: #fff; border:0;border-bottom: 3px solid #22ac38;font-size: 18px;">\n' +
                        '                                    回复数：'+list.length+'\n' +
                        '                                </div>\n' +
                        '                                <div style="margin-top: 50px;"></div>';

                    list.forEach(function (item, index) {

                        commentList += '                 <div class="discuss_list dis_column a_center j_center">\n' +
                            '                                        <div  onclick="replySub(\''+item.id+'\')" class="dis_row a_center discuss_list" style="height: 80px;width: 82%;">\n';
                        let margin_str = "";
                        if (item.headPortrait == '') {
                            margin_str = "";
                            commentList += '';
                        } else {
                            margin_str = "margin-left: 5%;";
                            commentList += '                             <div class="dis_row a_center discuss_list" style="width: 80px;">\n' +
                                '                                           <img src="' + item.headPortrait + '" style="height: 50px;width: 50px;border-radius: 50px;">\n' +
                                '                                        </div>\n';
                        }
                        if (item.isAnonymous == 1) {
                            commentList +=
                                '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">\n' +
                                '匿名用户\n' +
                                '                                            </div>\n';
                        } else {
                            commentList +=
                                '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">\n' +
                                item.userName + '\n' +
                                '                                            </div>\n';
                            if (item.isTeacher == 1) {
                                commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px; margin-left: 7px;color: #fe490a;border: 1px solid #fe490a;border-radius: 4px;padding: 3px 5px;">\n' +
                                    '                                                讲师\n' +
                                    '                                            </div>\n';
                            } else if (item.isStudent == 1) {
                                commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #fe9157;border: 1px solid #fe9157;border-radius: 4px;padding: 3px 5px;">\n' +
                                    '                                            学生\n' +
                                    '                                        </div>';
                            } else {
                                commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #666;border: 1px solid #666;border-radius: 4px;padding: 3px 5px;">\n' +
                                    '                                            其他用户\n' +
                                    '                                        </div>';
                            }
                            if (item.classesName != '') {
                                commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #999;background-color: #e8f9ff;border-radius: 4px;padding: 5px 5px;">\n' +
                                    item.classesName + ' \n' +
                                    '                                        </div>';
                            }
                            if (item.orgName != '') {
                                commentList += '                              <div class="dis_row a_center j_center discuss_list" style="height: auto;width: auto; font-size: 14px;margin-left: 7px;color: #999;background-color: #e9fff4;border-radius: 4px;padding: 5px 5px;">\n' +
                                    item.orgName + ' \n' +
                                    '                                        </div>';
                            }
                        }
                        if(item.fromUserName!=''){
                            commentList +=
                                '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: auto;margin-left: 7px;color: #000;">\n' +
                                '<span style="margin-left: 10px">回复</span><span style="margin-left: 10px">'+ item.fromUserName + '</span>\n' +
                                '                                            </div>\n';
                        }
                        if(item.isDelete == 1){
                            commentList += '                              </div>\n' +
                                '                                        <div  onclick="replySub(\''+item.id+'\')"  class="dis_row a_center j_center discuss_list" style="height: auto;width: 90%;">\n' +
                                '                                            <div class="dis_row a_center discuss_list" style="width: 90%;' + margin_str + 'color: #666;">\n' +
                                                                                '该评论已删除！\n' +
                                '                                            </div>\n' +
                                '                                        </div>\n';
                        }else {
                            commentList += '                              </div>\n' +
                                '                                        <div  onclick="replySub(\''+item.id+'\')"  class="dis_row a_center j_center discuss_list" style="height: auto;width: 90%;">\n' +
                                '                                            <div class="dis_row a_center discuss_list" style="width: 90%;' + margin_str + 'color: #666;">\n' +
                                item.content + '\n' +
                                '                                            </div>\n' +
                                '                                        </div>\n';
                        }

                        commentList += '\n' +
                            '                                        <div class="dis_row a_center j_center discuss_list" style="height: 80px;width: 82%;">\n' +
                            '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;font-size: 12px;">\n' +
                            item.addTime + '\n' +
                            '                                            </div>\n' +
                            '                                            <div class="dis_row a_center discuss_list" style="height: 80px;width: 50%;justify-content: flex-end;font-size: 12px;color: #666;">\n';
                        if (item.isCurrentUser == 1 && item.isDelete == 0) {
                            commentList += '                                  <span onclick="toDeleteComment(\''+item.id+'\')">删除</span>\n';
                        }
                        commentList += '                                      <span onclick="replySub(\''+item.id+'\')" style="margin-left: 10px;">回复</span>\n' +
                            '                                                <span style="margin-left: 10px;font-size: 18px;"></span>\n' +
                            '                                            </div>\n' +
                            '                                        </div>\n' +
                            '                                        <div class="dis_row a_center j_center discuss_list" style="height: 10px;background-color: #f7f7f7; "></div>\n' +
                            '                                    </div>';
                    });

                    $("#subCommentListDiv").html(commentList);
                }
            }
        });
    }

    function submit() {
        var is_mobi = navigator.userAgent.toLowerCase().match(/(ipod|iphone|android|coolpad|mmp|smartphone|midp|wap|xoom|symbian|j2me|blackberry|wince)/i) != null;
        ajaxToken("/jzApi/user/selUserDetail", "GET", {}, function (r) {
            // console.log("结果：" , r)
            // console.log(r.name)
            if (r.state == 1){
                // if (r.headPortrait != "" && r.headPortrait != null && r.name != "" && r.name != null && r.sex != "" &&
                //     r.sex != null && r.idNumber != "" && r.idNumber != null && r.mobile != "" && r.mobile != null &&
                //     r.dateOfBirth != "" && r.dateOfBirth != null && r.nation != "" &&
                //     r.nation != null && r.education != "" && r.education != null && r.major != "" && r.major != null &&
                //     r.politicalAffiliation != "" && r.politicalAffiliation != null && (r.officialCapacity != "" &&
                //         r.officialCapacity != null) && r.province != "" && r.province != null && r.province != "" && r.province != null &&
                //     r.city != "" && r.city != null && r.liveAddress != "" && r.liveAddress != null && r.experience != "" &&
                //     r.experience != null){

                ajaxToken("/jzApi/courses/selCourseOrder", "POST", {
                    id: $("#courseId").val()
                }, function (res) {
                    location.href = '/couInfo/courseSurePay?orderId=' + res.orderId + '&courseId=' + $("#courseId").val() + '&type=0';
                });
                // }else {
                //     layer.alert("完善个人信息才能报名该课程");
                // }
            }
            else if(r.state == 0){
                layer.alert("个人信息审核通过才能报名该课程");
            }else if(r.state == 3){
                if(is_mobi){
                    layer.confirm('完善个人信息才能报名该课程？', {
                        btn: ['确定','取消']
                    }, function(){

                        location.href = '/cultivate/my'
                    });
                }else{
                    layer.alert("完善个人信息才能报名该课程");
                }

            }

        })


    }

    function selChapterList() {
        $.ajax({
            url: "/jzApi/courses/selChapterList",
            type: 'GET',
            data: {id: $("#courseId").val()},
            success: function (res) {
                console.log(res);
                if (res.data == 0) {
                    $("#chapterList").html('<div class="noData">暂无数据</div>');
                } else {
                    let list = res.data;
                    let categoryList = '';
                    let chapterId='';
                    list.forEach(function (item, index) {
                        let resourceList = item.resources;
                        let width_margin_left= item.level*30;
                        let width_span= 100-(item.level*3);
                        let titleFontSize = 18;
                        if((item.level+'')!='0'){
                            titleFontSize = 16;
                        }
                        let resourceListStr='';

                        if(item.level==0){
                            chapterId=item.id;
                            resourceListStr ='<div class="list"><span onclick="ShrinkChapter('+item.id+','+item.level+')" class="chapterTitle" style="margin-left: '+width_margin_left+'px;width: '+width_span+'%;font-size: '+titleFontSize+'px;">'+item.name+'</span>';
                        }else {
                            resourceListStr ='<div class="list" name="chapter_'+chapterId+'" id="chapter_'+chapterId+'"><span class="chapterTitle" style="margin-left: '+width_margin_left+'px;width: '+width_span+'%;font-size: '+titleFontSize+'px;">'+item.name+'</span>';
                        }// style="display:block;"

                        let a = '';
                        if (item.isFree==0) {
                            a='<text style="color:#005c34">(可试看)</text>'
                        }

                        resourceList.forEach(function (item2,index2){
                            console.log(resourceList)
                            resourceListStr+='<div class="chapter"><a href="/cultivate/study/studyChapter?id=' + item2.id +'&chapterId='+item2.chapterId+ '&courseId=' + $("#courseId").val() + '">' +
                                '<div class="cpt"></div>' +
                                '<span class="cpt" style="margin-left: '+width_margin_left+'px;">' + item2.name +'</span class="cpt">' +
                                '<span class="min">' + a+ item2.videoDuration + '</span>' +
                                '<div style="clear: both"></div></a></div>';
                        });
                        categoryList += resourceListStr+'</div>';
                    });
                    $("#chapterList").html(categoryList);
                    // console.log($("#chapter_1395561514134741000").attr('name'));
                }
            }
        });
    }
    function ShrinkChapter(id) {
        let display =$("#chapter_" + id).css('display');
        //console.log("display:"+display);
        if(display == 'none') {
            let str="<i class=\"layui-icon layui-icon-down\" aria-hidden=\"true\"></i>";
            $('#icon_' + id).html(str);
        }else {
            let str="<i class=\"layui-icon layui-icon-right\" aria-hidden=\"true\"></i>";
            $('#icon_' + id).html(str);
        }
        $("#chapterList").find(".chapter_" + id).toggle();
    }

    //配套资源
    function selExtendList() {
        $.ajax({
            url: "/jzApi/courses/selExtendList",
            type: 'GET',
            data: {id: $("#courseId").val()},
            success: function (res) {
                // console.log(res)
                if (res.data == 0) {
                    $("#extendList").html('<div class="noData">暂无数据</div>');
                } else {
                    var list = res.data;
                    var categoryList = '';
                    list.forEach(function (item, index) {
                        var resourceList = item.resources;
                        var resourceListStr='<div class="list"><span class="chapterTitle">'+item.name+'</span>';
                        var a = '';
                        if (item.isFree==0) {
                            a='<text style="color:#005c34">(可试看)</text>'
                        }
                        if(resourceList.length>0){
                            resourceList.forEach(function (item2,index2){
                                // console.log(resourceList)
                                resourceListStr+='<div class="chapter"><a href="/cultivate/study/studyChapter?id=' + item2.id +'&chapterId='+item2.chapterId+ '&courseId=' + $("#courseId").val() + '">' +
                                    '<div class="cpt"></div>' +
                                    '<span class="cpt">' + item2.name +'</span class="cpt">' +
                                    '<span class="min">' + a+ item2.videoDuration + '</span>' +
                                    '<div style="clear: both"></div></a></div>';
                            });
                        }else{
                            resourceListStr+='<div class="chapter"><div class="noData">暂无数据</div></div>';
                        }
                        categoryList += resourceListStr+'</div>';

                    });
                    $("#extendList").html(categoryList);
                }
            }
        });
    }

    function questions() {
        $.ajax({
            url:'/jzApi/courses/selCoustuQueAns',
            type: 'GET',
            data: {courseId: $("#courseId").val() ,current:1, number:10},
            success:function (r) {
                var list = r.data.records;
                var Q = '';
                var a = 1;
                list.forEach(function (item, index) {
                    Q += '<div>' +
                        '  <span class="no">'+(a+index)+'、</span>' +
                        '  <span>Q：<span class="q_a">'+item.contents+'</span></span>' +
                        '</div>' +
                        '<div>' +
                        '  <span class="no"></span>' +
                        '  <span>A：<span class="q_a">'+item.answers+'</span></span>' +
                        '</div><hr/>';
                })
                $("#courseAsk").html(Q);
              //  page(1,r.data.pages);
            }
        })
    }

   /* function page(num, tolPages) {
        $("#page").paging({
            nowPage: Number(num), // 当前页码
            pageNum: Number(tolPages), // 总页码
            buttonNum: 10, //要展示的页码数量
            canJump: 1,// 是否能跳转。0=不显示（默认），1=显示
            showOne: 0,//只有一页时，是否显示。0=不显示,1=显示（默认）
            callback: function (num) { //回调函数
                $.ajax({
                    url: "/jzApi/courses/selCoustuQueAns",
                    type: 'GET',
                    data: {
                        current: num,
                        number: 10,
                        courseId: $("#courseId").val()
                    },
                    success: function (r) {
                        var list = r.data.records;
                        var Q = '';
                        var a = 1;
                        list.forEach(function (item, index) {
                            Q += '<div>' +
                                '  <span class="no">'+(a+index)+'、</span>' +
                                '  <span>Q：<span class="q_a">'+item.contents+'</span></span>' +
                                '</div>' +
                                '<div>' +
                                '  <span class="no"></span>' +
                                '  <span>A：<span class="q_a">'+item.answers+'</span></span>' +
                                '</div>';
                        })
                        $("#courseAsk").html(Q);
                    }
                });
            }
        });
    }
*/
</script>

</html>